package com.demo.springdemo.controller;
import com.demo.springdemo.pojo.ResponseMessage;
import com.demo.springdemo.pojo.User;
import com.demo.springdemo.pojo.dto.UserDto;
import com.demo.springdemo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController // 接口方法返回值为json
@RequestMapping("/user")  // 前缀 localhost:8080/user
public class User_controller {

    @Autowired
    IUserService userService;
    //REST
    //增加
    @PostMapping
    public String add(@RequestBody UserDto user){//提示传入文本
        User userNew= userService.add(user);
        return ResponseMessage.success(userNew).toString();
    }
    //查询@GetMapping
    //修改@PutMapping
    //删除@DeleteMapping

}
